package cn.haiway.drools.execute.service;

import cn.haiway.drools.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Haiway  on 2019/4/19
 */
@Service
public class RedisService {

    @Resource
    @Qualifier("byteRedisTemplate")
    RedisTemplate byteRedisTemplate;

    public byte[] getKjar(String groupId, String artifactId, String version) {
        String key = RedisUtil.kjarKey(groupId, artifactId, version);
        byte[] jar = RedisUtil.valueGet(key, byteRedisTemplate);

        return jar;
    }

    public void setKjar( String groupId, String artifactId, String version, byte[] kjar) {
        String key = RedisUtil.kjarKey(groupId, artifactId, version);
        RedisUtil.valueAdd(key, kjar, byteRedisTemplate);
    }
}
